/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * imagePanel.java
 *
 * Created on Mar 8, 2012, 12:27:29 PM
 */
package dip;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;


/**
 *
 * @author computer
 */
public class ImagePanel extends JPanel {

    /** Creates new form imagePanel */
    public ImagePanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if ( currentImage != null) g.drawImage(currentImage, 0, 0, null);
    }
    public void  setImage(File image) throws IOException
    {
        this.mainImage = ImageIO.read(image);
        this.currentImage = ImageIO.read(image);
        this.setPreferredSize(new Dimension(mainImage.getWidth(), mainImage.getHeight()));
        this.revalidate();
        this.repaint();
    }
    BufferedImage mainImage,currentImage;
}
